package com.example.logic;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.example.data.*;
//import com.example.weather.MainActivity;

public class CityManage {
			private Context context;
			public CityManage(Context context){
				this.context = context;
				
			}
			public String[] searchItem(String cityName){
				DbHelper dbhelper = new DbHelper(context, "weather");
				SQLiteDatabase db = dbhelper.getReadableDatabase();
				
				String [] value =new String[1];
				value[0]=cityName +"%";
				Cursor cursor = db.rawQuery("select *from weather where city like?",value);
				String []citys = new String[cursor.getCount()];
				while(cursor.moveToNext()){
					String city = cursor.getString(0);
					int id = cursor.getInt(1);
					
					citys[cursor.getPosition()]= city;
				}
				return citys;
			}
}
